﻿using dz.u9.jky.schema.Common;
using dz.u9.jky.schema.Customer;
using dz.u9.jky.schema.GL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UFIDA.U9.CBO.SCM.Customer;
using UFIDA.U9.ISV.GL.ISVGLImportSV;

namespace dz.inner.jky.api.service
{
    internal class VoucherService : BaseService
    {
        public U9CResult Add(DzISVImportVoucherDTO dto)
        {
            return util.U9Invoke(__Add, dto);
        }

        private U9CResult __Add(DzISVImportVoucherDTO dto)
        {
            U9CResult result = new U9CResult();

            ISVGLImportSV svc = new ISVGLImportSV();

            svc.ImportVoucherDTOs = Convert(dto);

            List<ISVReturnVoucherDTO> rtn = svc.Do();

            result.IsSuccess = true;
            result.DocNo = rtn[0].DocNo;
            result.Id = rtn[0].VoucherID;

            
            return result;
        }

        private List<ISVImportVoucherDTO> Convert(DzISVImportVoucherDTO dtovoucehr)
        {
            ISVImportVoucherDTO dto = new ISVImportVoucherDTO();

            ObjectCopyUtil util = new ObjectCopyUtil();

            util.CopyProperty(dtovoucehr, ref dto);


            List<ISVImportVoucherDTO> rtn = new List<ISVImportVoucherDTO>() { dto };

            return rtn;
        }
    }
}
